package icom.acm.manager.mircblog_mongo;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

import icom.acm.bean.mircblog.VIEW_USER_MBMESSAGE;
import icom.acm.util.mongo.MongoDB;
import icom.acm.util.mongo.FieldMongoType;

public class View_User_MBMessageMongoMgr {
	private MongoDB init(){
		MongoDB dbmongo = MongoDB.newInstance();
		dbmongo.getCollection("VIEW_USER_MBMESSAGE");
		return dbmongo;
	}
	
	public void insert(VIEW_USER_MBMESSAGE vumm) {
		MongoDB mongodb = init();
		DBObject obj = vumm.getDBObject();		
		mongodb.insert(obj);		
	}
	
	public DBObject findByMid(String msgid, MongoDB mongodb) {
		BasicDBObject arg = new BasicDBObject();		
		arg = mongodb.addTerm(arg, "VUMM_M_ID", 
				FieldMongoType.EQUAL, msgid, 
				FieldMongoType.INTEGER);
		mongodb.getCollection("VIEW_USER_MBMESSAGE");
		mongodb.find(arg);				
		DBObject obj = null;
		try {
			obj = mongodb.next();
		}catch(RuntimeException ex){	// no more
			
		}
		//T_MB_MESSAGE e = new T_MB_MESSAGE(obj);
		return obj;
	}
}
